<?php
namespace Admin\Controller;

use Think\Controller;

class UploadController extends AdminController
{
    public function index()
    {
        $this->display();  
    }

    public function load()
    {
        $upload=new \Think\Upload();
    	$upload->max->Size=3145678;
    	$upload->exts=array('jpg','gif','png','jpeg');
    	$upload->rootPath='./Uploads';
    	$upload->savePath='/';
    	$upload->saveName='com_create_guid';
    	$upload->autoSub = true;
        $upload->subName = array('date','Ymd');
    	$info=$upload->upload();
    	if (!$info) {
    		$this->error($upload->getError());
    	} else {
    		// $this->success('上传成功');
    		foreach($info as $file){
    			$filepath = $file['savepath'].$file['savename'];
    			echo $filepath;
    		}
    	}

    	$image=new \Think\Image();
    	$image->open('./Uploads'.$filepath);
    	$image->thumb(50,50,\Think\Image::IMAGE_THUMB_FIXED)->save('./Uploads/thumb/'.$file['savename']);
    }
}    